<?php
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: config.phtml 4816 2010-08-24 06:35:48Z huuphuoc $
 * @since		2.0.8
 */
?>
<?php 
$this->headTitle($this->translator('locale_config_page_title'));
?>
<div class="grid_12 t_a_ui_breadcrumb">
	<span><?php echo $this->translator('locale_config_breadcrumb'); ?></span>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>

<div class="grid_12 t_a_bottom">
<form method="post" action="<?php echo $this->url(array(), 'core_locale_config'); ?>">
	<div class="prefix_1 suffix_1">
		<div class="clearfix t_a_bottom">
			<label><?php echo $this->translator('locale_config_default_language'); ?>:</label>
			<select name="defaultLanguage">
				<?php foreach ($this->locales as $code => $locale) : ?>
				<option value="<?php echo $locale['code']; ?>"<?php if ($this->defaultLanguage == $locale['code']): ?> selected="selected"<?php endif; ?>><?php echo $locale['localName']; ?> (<?php echo $locale['englishName']; ?>)</option>
				<?php endforeach; ?>
			</select>
		</div>
	
		<hr />
	
		<div class="clearfix t_a_bottom">
			<div class="grid_2 alpha"><label>&nbsp;</label></div>
			<div class="grid_8 omega">
				<input type="checkbox" name="localizeEnable" id="localizeEnable"<?php if ($this->enable) : ?> checked="checked"<?php endif; ?> /> <?php echo $this->translator('locale_config_enable_multilingual'); ?>
			</div>
		</div>
	
		<div id="localization" style="display: <?php if ($this->enable) : ?>block<?php else : ?>none<?php endif; ?>">
			<hr />
			
			<div class="clearfix t_a_bottom">
				<div class="grid_2 alpha">
					<label><?php echo $this->translator('locale_config_supported_languages'); ?>:</label>
				</div>
				<div class="grid_8 omega">
					<?php foreach (array_values($this->locales) as $index => $locale) : ?>
					<div class="grid_4 <?php if ($index % 2 == 0) : ?>alpha<?php else : ?>omega<?php endif; ?> t_a_bottom">
						<input type="checkbox" name="supportedLanguages[]" value="<?php echo $locale['code']; ?>"<?php if (in_array($locale['code'], $this->availableLanguages)) : ?> checked="checked"<?php endif; ?> /> <img src="<?php echo $this->APP_STATIC_SERVER; ?>/images/flags/<?php echo $locale['code']; ?>.png" /> <?php echo $locale['localName']; ?> (<?php echo $locale['englishName']; ?>)
					</div>
					<?php endforeach; ?>
				</div>
			</div>
			
			<hr />
			
			<div class="clearfix t_a_bottom">
				<div class="grid_2 alpha"><label>&nbsp;</label></div>
				<div class="grid_8 omega">
					<input type="checkbox" name="autoTranslate" id="autoTranslate"<?php if ('true' == $this->config['translate']['auto']) : ?> checked="checked"<?php endif; ?> /> <?php echo $this->translator('locale_config_auto_translate'); ?>
				</div>
			</div>
			
			<div id="translatorService" class="clearfix t_a_bottom" style="display: <?php if ('true' == $this->config['translate']['auto']) : ?>block<?php else : ?>none<?php endif; ?>">
				<div class="grid_2 alpha"><label>&nbsp;</label></div>
				<div class="grid_4">
					<div class="t_a_bottom">
						<input type="radio" name="service" value="google"<?php if ('google' == $this->config['translate']['service']['using']) : ?> checked="checked"<?php endif; ?> /> <?php echo $this->translator('locale_config_google_translate_service'); ?>						
					</div>
					<textarea style="width: 300px; height: 100px" name="googleApiKey"><?php echo $this->config['translate']['service']['google']['apikey']; ?></textarea>
				</div>
				<div class="grid_4 omega">
					<div class="t_a_bottom">
						<input type="radio" name="service" value="microsoft"<?php if ('microsoft' == $this->config['translate']['service']['using']) : ?> checked="checked"<?php endif; ?> /> <?php echo $this->translator('locale_config_microsoft_translate_service'); ?>						
					</div>
					<textarea style="width: 300px; height: 100px" name="microsoftApiKey"><?php echo $this->config['translate']['service']['microsoft']['apikey']; ?></textarea>
				</div>
			</div>
		</div>
		
		<hr />
		
		<div class="clearfix t_a_bottom">
			<label>&nbsp;</label>
			<button type="submit"><span><?php echo $this->translator('locale_config_save_button'); ?></span></button>
		</div>
	</div>
</form>
</div>

<script type="text/javascript">
$(document).ready(function() {
	$('#localizeEnable').change(function() {
		$('#localization').toggle();
	});

	$('#autoTranslate').change(function() {
		$('#translatorService').toggle();
	});
});
</script>

